<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class interprocess_condition</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../interprocess/indexes_reference.html#doxygen.boost_interprocess_header_reference.interprocess__condition_8hpp" title="Header &lt;boost/interprocess/sync/interprocess_condition.hpp&gt;">
<link rel="prev" href="classboost_1_1interprocess_1_1file__lock.html" title="Class file_lock">
<link rel="next" href="classboost_1_1interprocess_1_1interprocess__condition__any.html" title="Class interprocess_condition_any">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1interprocess_1_1file__lock.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../interprocess/indexes_reference.html#doxygen.boost_interprocess_header_reference.interprocess__condition_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="classboost_1_1interprocess_1_1interprocess__condition__any.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class interprocess_condition</span></h2>
<p>boost::interprocess::interprocess_condition</p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../interprocess/indexes_reference.html#doxygen.boost_interprocess_header_reference.interprocess__condition_8hpp" title="Header &lt;boost/interprocess/sync/interprocess_condition.hpp&gt;">boost/interprocess/sync/interprocess_condition.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html" title="Class interprocess_condition">interprocess_condition</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>

  <span class="comment">// <a class="link" href="../boost_container_header_reference/classboost_1_1container_1_1pmr_1_1memory__resource.html#id77-bb">public member functions</a></span>
  <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a7fc15a5ebe3774056ef5f2dbfde0b83f"><span class="identifier">interprocess_condition</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a3ac151debf9a6a30bd1b3e20128c0b8d"><span class="special">~</span><span class="identifier">interprocess_condition</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1af36201a87a4b312f16a902613a152966"><span class="identifier">notify_one</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a625140964384f21f4f44248b0702dc8c"><span class="identifier">notify_all</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a3f9ef691d26ffebc1e19cc820f683068"><span class="identifier">wait</span></a><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> Pr<span class="special">&gt;</span> <span class="keyword">void</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a0ca99e056250293e2f0cf69f3bb9b9d7"><span class="identifier">wait</span></a><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">Pr</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> TimePoint<span class="special">&gt;</span> 
    <span class="keyword">bool</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1aa65a9ea5020329dbf4f8d44a88ae300e"><span class="identifier">timed_wait</span></a><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">TimePoint</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> TimePoint<span class="special">,</span> <span class="keyword">typename</span> Pr<span class="special">&gt;</span> 
    <span class="keyword">bool</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1ab0d9bbdd4aa7af2aa0137341c7f14a21"><span class="identifier">timed_wait</span></a><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">TimePoint</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">Pr</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> TimePoint<span class="special">&gt;</span> 
    <span class="identifier">cv_status</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a50e8e156fd5e7d56cb4706a89dcd94c1"><span class="identifier">wait_until</span></a><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">TimePoint</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> TimePoint<span class="special">,</span> <span class="keyword">typename</span> Pr<span class="special">&gt;</span> 
    <span class="keyword">bool</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a1a1ce83bed2cb45006f26d5a511d0c4a"><span class="identifier">wait_until</span></a><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">TimePoint</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">Pr</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> Duration<span class="special">&gt;</span> 
    <span class="identifier">cv_status</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a271d6365b7e651309ea99fba9dd16d80"><span class="identifier">wait_for</span></a><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Duration</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> Duration<span class="special">,</span> <span class="keyword">typename</span> Pr<span class="special">&gt;</span> 
    <span class="keyword">bool</span> <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1acd762fb53a969ceddef7a2f769b8cc0b"><span class="identifier">wait_for</span></a><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Duration</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">Pr</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.16.19.3.58.4.4"></a><h2>Description</h2>
<p>This class is a condition variable that can be placed in shared memory or memory mapped files. Destroys the object of type std::condition_variable_any</p>
<p>Unlike std::condition_variable in C++11, it is NOT safe to invoke the destructor if all threads have been only notified. It is required that they have exited their respective wait functions. </p>
<div class="refsect2">
<a name="id-1.3.16.19.3.58.4.4.4"></a><h3>
<a name="id77-bb"></a><code class="computeroutput">interprocess_condition</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a7fc15a5ebe3774056ef5f2dbfde0b83f"></a><span class="identifier">interprocess_condition</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>Constructs a <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html" title="Class interprocess_condition">interprocess_condition</a>. On error throws <a class="link" href="classboost_1_1interprocess_1_1interprocess__exception.html" title="Class interprocess_exception">interprocess_exception</a>. </li>
<li class="listitem">
<pre class="literallayout"><a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a3ac151debf9a6a30bd1b3e20128c0b8d"></a><span class="special">~</span><span class="identifier">interprocess_condition</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Destroys *this liberating system resources. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1af36201a87a4b312f16a902613a152966"></a><span class="identifier">notify_one</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>If there is a thread waiting on *this, change that thread's state to ready. Otherwise there is no effect. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a625140964384f21f4f44248b0702dc8c"></a><span class="identifier">notify_all</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Change the state of all threads waiting on *this to ready. If there are no waiting threads, <a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a625140964384f21f4f44248b0702dc8c">notify_all()</a> has no effect. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">&gt;</span> <span class="keyword">void</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a3f9ef691d26ffebc1e19cc820f683068"></a><span class="identifier">wait</span><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span> lock<span class="special">)</span><span class="special">;</span></pre>
<p>Releases the lock on the <a class="link" href="classboost_1_1interprocess_1_1interprocess__mutex.html" title="Class interprocess_mutex">interprocess_mutex</a> object associated with lock, blocks the current thread of execution until readied by a call to this-&gt;<a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1af36201a87a4b312f16a902613a152966">notify_one()</a> or this-&gt;<a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a625140964384f21f4f44248b0702dc8c">notify_all()</a>, and then reacquires the lock. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> Pr<span class="special">&gt;</span> <span class="keyword">void</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a0ca99e056250293e2f0cf69f3bb9b9d7"></a><span class="identifier">wait</span><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span> lock<span class="special">,</span> <span class="identifier">Pr</span> pred<span class="special">)</span><span class="special">;</span></pre>
<p>The same as: while (!pred()) wait(lock) </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> TimePoint<span class="special">&gt;</span> 
  <span class="keyword">bool</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1aa65a9ea5020329dbf4f8d44a88ae300e"></a><span class="identifier">timed_wait</span><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span> lock<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">TimePoint</span> <span class="special">&amp;</span> abs_time<span class="special">)</span><span class="special">;</span></pre>
<p>Releases the lock on the <a class="link" href="classboost_1_1interprocess_1_1interprocess__mutex.html" title="Class interprocess_mutex">interprocess_mutex</a> object associated with lock, blocks the current thread of execution until readied by a call to this-&gt;<a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1af36201a87a4b312f16a902613a152966">notify_one()</a> or this-&gt;<a class="link" href="classboost_1_1interprocess_1_1interprocess__condition.html#doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a625140964384f21f4f44248b0702dc8c">notify_all()</a>, or until time abs_time is reached, and then reacquires the lock. Returns: false if time abs_time is reached, otherwise true. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> TimePoint<span class="special">,</span> <span class="keyword">typename</span> Pr<span class="special">&gt;</span> 
  <span class="keyword">bool</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1ab0d9bbdd4aa7af2aa0137341c7f14a21"></a><span class="identifier">timed_wait</span><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span> lock<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">TimePoint</span> <span class="special">&amp;</span> abs_time<span class="special">,</span> <span class="identifier">Pr</span> pred<span class="special">)</span><span class="special">;</span></pre>
<p>The same as: while (!pred()) { if (!timed_wait(lock, abs_time)) return pred(); } return true; </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> TimePoint<span class="special">&gt;</span> 
  <span class="identifier">cv_status</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a50e8e156fd5e7d56cb4706a89dcd94c1"></a><span class="identifier">wait_until</span><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span> lock<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">TimePoint</span> <span class="special">&amp;</span> abs_time<span class="special">)</span><span class="special">;</span></pre>
<p>Same as <code class="computeroutput">timed_wait</code>, but this function is modeled after the standard library interface. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> TimePoint<span class="special">,</span> <span class="keyword">typename</span> Pr<span class="special">&gt;</span> 
  <span class="keyword">bool</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a1a1ce83bed2cb45006f26d5a511d0c4a"></a><span class="identifier">wait_until</span><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span> lock<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">TimePoint</span> <span class="special">&amp;</span> abs_time<span class="special">,</span> <span class="identifier">Pr</span> pred<span class="special">)</span><span class="special">;</span></pre>
<p>Same as <code class="computeroutput">timed_wait</code>, but this function is modeled after the standard library interface. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> Duration<span class="special">&gt;</span> 
  <span class="identifier">cv_status</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1a271d6365b7e651309ea99fba9dd16d80"></a><span class="identifier">wait_for</span><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span> lock<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Duration</span> <span class="special">&amp;</span> dur<span class="special">)</span><span class="special">;</span></pre>
<p>Same as <code class="computeroutput">timed_wait</code>, but this function is modeled after the standard library interface and uses relative timeouts. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> L<span class="special">,</span> <span class="keyword">typename</span> Duration<span class="special">,</span> <span class="keyword">typename</span> Pr<span class="special">&gt;</span> 
  <span class="keyword">bool</span> <a name="doxygen.boost_interprocess_header_reference.classboost_1_1interprocess_1_1interprocess__condition_1acd762fb53a969ceddef7a2f769b8cc0b"></a><span class="identifier">wait_for</span><span class="special">(</span><span class="identifier">L</span> <span class="special">&amp;</span> lock<span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Duration</span> <span class="special">&amp;</span> dur<span class="special">,</span> <span class="identifier">Pr</span> pred<span class="special">)</span><span class="special">;</span></pre>
<p>Same as <code class="computeroutput">timed_wait</code>, but this function is modeled after the standard library interface and uses relative timeouts </p>
</li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2005-2024 Ion Gaztanaga<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="classboost_1_1interprocess_1_1file__lock.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../interprocess/indexes_reference.html#doxygen.boost_interprocess_header_reference.interprocess__condition_8hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="classboost_1_1interprocess_1_1interprocess__condition__any.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
